package org.rsbot.gui;

import java.awt.Dimension;
import java.awt.Toolkit;
import java.io.File;
import javax.swing.BorderFactory;

import javax.swing.GroupLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.LayoutStyle;
import javax.swing.UIManager;
import org.rsbot.util.GlobalConfiguration;

public class UpdateGUI extends JFrame {

    private static final long serialVersionUID = 8646183995455154141L;
    public static JLabel jLabel1 = new JLabel();
    public static JLabel jLabel2 = new JLabel();
    public static JLabel jLabel3 = new JLabel();
    public static int percent = 0;

    public UpdateGUI() {
        try {
            setIconImage(Toolkit.getDefaultToolkit().getImage(GlobalConfiguration.RUNNING_FROM_JAR ? getClass().getResource(GlobalConfiguration.Paths.Resources.ICON) : new File(GlobalConfiguration.Paths.ICON).toURI().toURL()));
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (final Exception e) {
        }
        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        setResizable(false);
        setTitle("Runedev Updater");

        JPanel panel1 = new JPanel();
        panel1.setBorder(BorderFactory.createTitledBorder(" Downloading update... "));
        panel1.setMaximumSize(new Dimension(245, 510));
        panel1.setPreferredSize(new Dimension(210, 500));
        panel1.setRequestFocusEnabled(false);
        try {
            jLabel1.setIcon(new javax.swing.ImageIcon(Toolkit.getDefaultToolkit().getImage(GlobalConfiguration.RUNNING_FROM_JAR ? getClass().getResource(GlobalConfiguration.Paths.Resources.TRAY_HIDE) : new File(GlobalConfiguration.Paths.TRAY_HIDE).toURI().toURL())));
        } catch (final Exception e) {
            e.printStackTrace();
        }
        jLabel2.setText("Please be patient wile your new client is being downloaded");
        jLabel3.setText("");

        GroupLayout jPanel1Layout = new GroupLayout(panel1);
        panel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
                jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(jPanel1Layout.createSequentialGroup().addContainerGap().addComponent(jLabel1).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(jLabel3, GroupLayout.DEFAULT_SIZE, 289, Short.MAX_VALUE).addComponent(jLabel2, GroupLayout.DEFAULT_SIZE, 289, Short.MAX_VALUE)).addContainerGap()));
        jPanel1Layout.setVerticalGroup(
                jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(jPanel1Layout.createSequentialGroup().addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING, false).addComponent(jLabel1).addGroup(jPanel1Layout.createSequentialGroup().addComponent(jLabel2).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addComponent(jLabel3))).addContainerGap(19, Short.MAX_VALUE)));

        GroupLayout layout = new GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
                layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addContainerGap().addComponent(panel1, GroupLayout.DEFAULT_SIZE, 379, Short.MAX_VALUE).addContainerGap()));
        layout.setVerticalGroup(
                layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addComponent(panel1, GroupLayout.PREFERRED_SIZE, 97, GroupLayout.PREFERRED_SIZE).addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));

        pack();
        setLocationRelativeTo(getOwner());
        setVisible(true);
    }
}
